import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class Test {
    public static void main(String[] args) {
        String[] words = {"nothing", "nothing", "someone", "some", "body"};
        Map<String, Integer> map = countWorld(words);
        Set<Map.Entry<String, Integer>> entrySet = map.entrySet();
        for(Map.Entry<String, Integer> entry : entrySet){
            System.out.println("key: " + entry.getKey() + "; val: " + entry.getValue());
        }
    }
    public static Map<String, Integer> countWorld(String[] words){
        Map<String, Integer> map = new HashMap<>();
        for(String s : words){
            if(map.get(s) == null){
                map.put(s, 1);
            }else{
                int val = map.get(s);
                map.put(s, val+1);
            }
        }
        return map;
    }
}
